package com.be.beadmin.basicData.controller;

import com.be.beadmin.basicData.entity.Supplier;
import com.be.beadmin.common.entity.PageEntity;
import com.be.beadmin.basicData.service.SupplierService;
import com.be.beadmin.basicData.dto.input.SupplierQueryCriteria;
import com.be.beadmin.basicData.dto.input.SupplierDto;
import org.springframework.data.domain.Pageable;
import com.be.beadmin.common.utils.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenwei
* @date 2022-12-23
**/
@RestController
public class SupplierController {

    @Autowired
    private  SupplierService supplierService;


    @PostMapping(value = "/basicData/getSupplierByPage")
    public ResultModel getSupplierByPage(@RequestBody PageEntity pageEntity)  {
        return ResultModel.success(supplierService.getSupplierByPage(pageEntity)) ;
    }

    @PostMapping("/basicData/addSupplier")
    public ResultModel addSupplier(@RequestBody SupplierDto supplierDto){
        supplierService.addSupplier(supplierDto);
        return ResultModel.success(ResultModel.ADD);
    }

    @PostMapping("/basicData/delSupplier")
    public ResultModel delSupplier(@RequestBody SupplierDto supplierDto){
        supplierService.delSupplier(supplierDto.getId());
        return ResultModel.success(ResultModel.DELETE);
    }


    @PostMapping("/basicData/updateSupplier")
    public ResultModel updateSupplier(@RequestBody SupplierDto supplierDto){
        supplierService.updateSupplier(supplierDto);
        return ResultModel.success(ResultModel.UPDATE);
    }
}